<template>
  <el-drawer v-model="addDrawer" size="45%" :show-close="false" @opened="openDrawer" @close="closeDrawer">
    <template #title>
      <h2><svg-icon icon-class="list"></svg-icon><span style="padding-left: 15px">{{typeName}}</span></h2>
      <el-button type="primary" @click="confirmClick" :disabled="drawerLoading" v-if="isShowSave">保存</el-button>
    </template>
    <template #default>
      <el-form :model="form" ref="addRef" :inline="true" :rules="formRules" label-width="140px" v-loading="drawerLoading">
        <el-row justify="space-between">
          <el-form-item label="省">
            <el-input v-model="form.province" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" clearable disabled></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="区/县">
            <el-input v-model="form.county" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="异常点编号" prop="id">
            <el-input v-model="form.id" placeholder="请输入异常点编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="所属测线编号" prop="svyLineId">
            <el-input v-model="form.svyLineId" placeholder="请输入所属测线编号" clearable maxlength="17"></el-input>
          </el-form-item>
          <el-form-item label="目标断层编号" prop="targetFaultId">
            <el-input v-model="form.targetFaultId" placeholder="请输入目标断层编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="目标断层来源" prop="targetFaultSource">
            <dict-select code="FaultSourceCVD" :value="form.targetFaultSource" @update="updateDict('targetFaultSource', $event)"></dict-select>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="目标断层名称" prop="targetFaultName" style="width: 100%">
            <el-input v-model="form.targetFaultName" placeholder="请输入目标断层名称" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea"
              show-word-limit maxlength="50" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="距起点距离" prop="distance">
            <el-input v-model="form.distance" placeholder="请输入距起点距离" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="异常分类" prop="abnormalType" style="width: 100%">
            <el-input v-model="form.abnormalType" placeholder="请输入异常分类" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea"
              show-word-limit maxlength="40" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="显示码" prop="showCode">
            <el-input v-model="form.showCode" placeholder="请输入显示码" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="备注" prop="commentInfo" style="width:100%">
            <el-input v-model="form.commentInfo" placeholder="请输入备注" :autosize="{ minRows: 6, maxRows: 12 }"
              type="textarea" show-word-limit maxlength="2147483647" clearable></el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </template>
  </el-drawer>
</template>
<script setup>
import useSpatialData from '@/hooks/useSpatialData'
import { eightDouble, fourInt } from '@/utils/validate'
const { route, addDrawer, drawerLoading, form, typeName, openDrawer, closeDrawer, confirmClick, updateDict, isShowSave } = useSpatialData()
const formRules = {
  id: [{ required: true, message: '请填写异常点编号！', trigger: 'blur' }],
  svyLineId: [{ required: true, message: '请填写所属测线编号！', trigger: 'blur' }],
  targetFaultSource: [{ required: true, message: '请填写目标断层来源！', trigger: 'blur' }],
  distance: [eightDouble],
  showCode: [fourInt]
}
</script>
<style scoped></style>